<?php

namespace app\models;

use think\Db;
use think\Model;

class Order extends Model
{
    protected $pk = 'id';
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'created';
    protected $defaultSoftDelete = 0;


    public function getTypeTextAttr($value, $data)
    {
        $text = '';
        switch ($data['type']) {
            case '1':
                $text = '配送上门';
                break;
            case '2':
                $text = '到店自提';
                break;
            default:
                break;
        }
        return $text;
    }

    public function getStatusTextAttr($value, $data)
    {
        $text = '';
        switch ($data['status']) {
            case '1':
                $text = '待付款';
                if ($data['examine'] == 3) {
                    $text = $text . '[审核驳回]';
                }
                break;
            case '2':
                $text = '已付款';
                if ($data['examine'] == 1) {
                    $text = $text . '[审核中]';
                }
                if ($data['examine'] == 2) {
                    $text = '待运送';
                }
                break;
            case '3':
                $text = '运送中';
                break;
            case '4':
                $text = '已完成';
                break;
            case '5':
                $text = '已取消';
                break;
            default:
                # code...
                break;
        }
        return $text;
    }

    public function getPaymentTextAttr($value, $data)
    {
        $text = '';
        switch ($data['payment']) {
            case '0':
                $text = '无';
                break;
            case '1':
                $text = '线下付款';
                break;
            case '2':
                $text = '微信支付';
                break;
            case '3':
                $text = '抖音支付';
                break;
            case '4':
                $text = '余额支付';
                break;
            default:
                $text = '未知';
                break;
        }
        return $text;
    }
}
